﻿using System;
using System.Drawing;
using System.Windows.Forms;

namespace DtpInDgv
{
    [ToolboxBitmap(typeof(DataGridViewColumn))]
    public class CalendarColumn : DataGridViewColumn
    {
        public CalendarColumn()
            : base(new CalendarCell())
        {

        }
        public DateTime MinDate
        {
            get { return CalendarCell.CellMinDate; }
            set { CalendarCell.CellMinDate = value; }
        }
        public DateTime MaxDate
        {
            get { return CalendarCell.CellMaxDate; }
            set { CalendarCell.CellMaxDate = value; }
        }
        public override DataGridViewCell CellTemplate
        {
            get { return base.CellTemplate; }
            set
            {
                if (value != null && !value.GetType().IsAssignableFrom(typeof(CalendarCell)))
                {
                    throw new InvalidCastException("Must be a CalendarCell");
                }
                base.CellTemplate = value;
            } // Ensure that the cell used for the template is a CalendarCell.
        }
    }
}
